package com.cdtye.shuoh.mapper.tdengine;

import com.cdtye.shuoh.domain.tdengine.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;


@Repository
public interface TdEngineMapper {

    void createDatabase(@Param("dataBaseName") String dataBaseName);

    void createSuperTable(@Param("schemaFields") List<FieldsVo> schemaFields,
                          @Param("tagsFields") List<FieldsVo> tagsFields,
                          @Param("dataBaseName") String dataBaseName,
                          @Param("superTableName") String superTableName);

    void createTable(@Param("tagsFieldValues") List<Fields> tagsFieldValues,
                     @Param("tableName") String tableName,
                     @Param("dataBaseName") String dataBaseName,
                     @Param("superTableName") String superTableName);

    void insertData(TableDto tableDto);

    List<Map<String, Object>> selectByDeviceIdentificationAndChannelNo(@Param("dataBaseName") String dataBaseName, @Param("tableName")String tableName, @Param("cmdId") String cmdId, @Param("channelNo") String channelNo);

    List<Map<String, Object>> selectByTimestamp(SelectDto selectDto);

    void addColumnForSuperTable(@Param("superTableName") String superTableName,
                                @Param("fieldsVo") FieldsVo fieldsVo);

    void dropColumnForSuperTable(@Param("superTableName") String superTableName,
                                @Param("fieldsVo") FieldsVo fieldsVo);

    void addTagForSuperTable(@Param("superTableName") String superTableName,
                                @Param("fieldsVo") FieldsVo fieldsVo);

    void dropTagForSuperTable(@Param("superTableName") String superTableName,
                                 @Param("fieldsVo") FieldsVo fieldsVo);

    Map<String, Long> getCountByTimestamp(SelectDto selectDto);

    Integer checkTableExists(@Param("dataBaseName") String dataBaseName, @Param("tableName")String tableName);

    List<Map<String, Object>> getLastData(SelectDto selectDto);

    List<Map<String, Object>> getLastNumData(SelectDto selectDto);

    List<Map<String, Object>> getHistoryData(SelectVisualDto selectVisualDto);

    List<Map<String, Object>> getRealtimeData(SelectVisualDto selectVisualDto);

    List<Map<String, Object>> getAggregateData(SelectVisualDto selectVisualDto);

    List<Map<String, Object>> getLastDataByTags(TagsSelectDao tagsSelectDao);
}
